//
//  ZSCollectionViewCell.m
//  intelligent
//
//  Created by 甘世清 on 2024/3/27.
//

#import "ZSCollectionViewCell.h"

@implementation ZSCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.masksToBounds = YES;
        [self SQ_UIViewForSelfView];
    }
    return self;
}
/// 添加ui
-(void)SQ_UIViewForSelfView
{
    self.contentView.backgroundColor = SQColor(@"#EEEEEE");
    self.contentView.layer.cornerRadius = 20;
    self.contentView.clipsToBounds = YES;
    self.contentView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.bgImage];
    [self.bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
    }];
    [self.contentView addSubview:self.label1];
    [self.label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.top.equalTo(self.contentView).offset(23);
    }];
    [self.contentView addSubview:self.label2];
    [self.label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.top.equalTo(self.contentView).offset(63);
    }];
    
}
- (void)setModel:(VModel *)model{
    _model = model;
    if (model.isseleted) {
        _bgImage.hidden = NO;
        self.label1.textColor = SQColor666666;
        self.label2.textColor = SQColor333333;
       
    } else {
        _bgImage.hidden = YES;
        self.label1.textColor = SQColor999999;
        self.label2.textColor = SQColor999999;
       
    }
    self.label1.text = model.name;
    self.label2.text =[NSString stringWithFormat:@"%@%@",model.prefix,model.price];
    self.label2.keywords = model.prefix;
    self.label2.keywordsFont = FONT_MEDIUM(14);
    [self.label2 getLableSizeWithMaxWidth:100];
     
}
- (UIImageView *)bgImage{
    if (!_bgImage) {
        _bgImage = [[UIImageView alloc]init];
        _bgImage.image = SQGetImage(@"矩形备份 7");
        _bgImage.contentMode = UIViewContentModeScaleAspectFill;
        _bgImage.hidden = YES;
    }
    return _bgImage;
}
- (UILabel *)label1{
    if (!_label1) {
        _label1 = [[UILabel alloc]init];
        _label1.font = FONT_REGULAR(16);
        _label1.textColor = SQColor333333;
        _label1.textAlignment = NSTextAlignmentCenter;
    }
    return _label1;
}
- (UILabel *)label2{
    if (!_label2) {
        _label2 = [[UILabel alloc]init];
        _label2.font = FONT_MEDIUM(28);
        _label2.textColor = SQColor333333;
        _label2.textAlignment = NSTextAlignmentCenter;
    }
    return _label2;
}
@end
